```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库ACID特性详解 | 技术小馆</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #333;
            line-height: 1.8;
            background-color: #f9f9f9;
        }
        .hero-bg {
            background: linear-gradient(135deg, #3a7bd5 0%, #00d2ff 100%);
        }
        .acid-card {
            transition: all 0.3s ease;
            border-radius: 12px;
            box-shadow: 0 10px 20px rgba(0,0,0,0.1);
        }
        .acid-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 30px rgba(0,0,0,0.15);
        }
        .section-title {
            position: relative;
            padding-bottom: 15px;
        }
        .section-title:after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #3a7bd5 0%, #00d2ff 100%);
            border-radius: 2px;
        }
        .dropcap:first-letter {
            float: left;
            font-size: 3.5em;
            line-height: 0.8;
            margin: 0.15em 0.1em 0 0;
            color: #3a7bd5;
            font-weight: 700;
        }
    </style>
</head>
<body class="antialiased">
    <!-- Hero Section -->
    <section class="hero-bg text-white py-20 md:py-32 px-4 md:px-0">
        <div class="container mx-auto max-w-5xl text-center">
            <div class="flex justify-center mb-6">
                <div class="bg-white bg-opacity-20 rounded-full p-3 inline-flex">
                    <i class="fas fa-database text-3xl"></i>
                </div>
            </div>
            <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">数据库ACID特性详解</h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                探索数据库事务管理的核心原理，保障数据一致性与可靠性的关键技术
            </p>
            <div class="mt-10">
                <a href="#acid-principles" class="inline-block bg-white text-blue-600 font-medium px-6 py-3 rounded-full hover:bg-opacity-90 transition-all transform hover:-translate-y-1">
                    开始探索 <i class="fas fa-arrow-down ml-2"></i>
                </a>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <div class="container mx-auto max-w-5xl px-4 md:px-0 py-12 md:py-20">
        <!-- Introduction -->
        <section class="mb-20">
            <p class="text-lg md:text-xl text-gray-700 mb-8 dropcap">
                我们生活在一个数据驱动的时代，从银行转账到网上购物，每一项操作背后都涉及到复杂的数据处理过程。而这些数据处理的背后，是数据库系统在默默地保障数据的正确性和一致性。试想一下，如果银行系统不能保证你的每笔交易都是准确无误的，那将会带来多大的风险和混乱。因此，ACID特性在这种场景下显得尤为重要。
            </p>
            
            <div class="bg-white rounded-xl p-6 shadow-lg mb-10 acid-card">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 font-serif section-title">ACID概述</h2>
                <p class="mb-6">
                    ACID是Atomicity（原子性）、Consistency（一致性）、Isolation（隔离性）和Durability（持久性）的缩写，它们共同定义了事务处理在数据库系统中的行为和特性。这些特性确保了数据库事务的可靠性和数据的一致性。
                </p>
                <div class="mermaid">
                    graph LR
                    A[ACID] --> B[Atomicity<br>原子性]
                    A --> C[Consistency<br>一致性]
                    A --> D[Isolation<br>隔离性]
                    A --> E[Durability<br>持久性]
                </div>
            </div>
        </section>

        <!-- What is Transaction -->
        <section class="mb-20">
            <div class="bg-white rounded-xl p-6 shadow-lg acid-card">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 font-serif section-title">什么是事务</h2>
                <p class="mb-6">
                    在数据库系统中，<strong>事务（Transaction）</strong>是指一个由一个或多个SQL语句组成的逻辑工作单元，这些语句被视为一个整体，它们要么全部成功，要么全部失败。事务的目标是确保数据库中的数据在并发环境下仍然保持一致性和完整性。
                </p>
                
                <div class="grid md:grid-cols-2 gap-8 mt-8">
                    <div>
                        <h3 class="text-xl font-bold mb-4 flex items-center">
                            <i class="fas fa-check-circle text-blue-500 mr-2"></i> 事务的关键作用
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                <span><strong>数据一致性</strong>：确保数据库从一个一致性状态转换到另一个一致性状态</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                <span><strong>并发控制</strong>：管理多个事务对相同数据的访问，防止冲突</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                <span><strong>故障恢复</strong>：系统崩溃时能恢复到事务开始前的状态</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check text-green-500 mt-1 mr-2"></i>
                                <span><strong>简化编程</strong>：开发者可以专注于业务逻辑而不必担心一致性问题</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1719976266706-ee73377a-98db-4e8a-8ee0-c285df07da50.png" alt="事务示意图" class="rounded-lg shadow-md w-full h-auto">
                    </div>
                </div>
            </div>
        </section>

        <!-- ACID Principles -->
        <section id="acid-principles" class="mb-20">
            <h2 class="text-3xl md:text-4xl font-bold mb-12 text-center font-serif">ACID四大特性详解</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <!-- Atomicity -->
                <div class="bg-white rounded-xl p-6 shadow-lg acid-card">
                    <div class="flex items-center mb-4">
                        <div class="bg-blue-100 text-blue-600 p-3 rounded-full mr-4">
                            <i class="fas fa-atom text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">原子性 (Atomicity)</h3>
                    </div>
                    <p class="mb-4">
                        原子性确保事务中的所有操作作为一个不可分割的单元被执行。事务要么全部成功，要么全部失败，没有中间状态。
                    </p>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1719976334672-92767443-6700-40ed-8da7-d8253c3c2bab.png" alt="原子性示意图" class="rounded-lg mb-4 w-full h-auto">
                    <div class="bg-blue-50 p-4 rounded-lg">
                        <h4 class="font-bold text-blue-700 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 实现机制
                        </h4>
                        <ul class="list-disc pl-5 space-y-1 text-blue-800">
                            <li>日志记录 (Write-Ahead Logging)</li>
                            <li>回滚操作 (Rollback)</li>
                            <li>保存点 (Savepoints)</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Consistency -->
                <div class="bg-white rounded-xl p-6 shadow-lg acid-card">
                    <div class="flex items-center mb-4">
                        <div class="bg-green-100 text-green-600 p-3 rounded-full mr-4">
                            <i class="fas fa-balance-scale text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">一致性 (Consistency)</h3>
                    </div>
                    <p class="mb-4">
                        一致性确保事务在执行前后，数据库都保持一致状态。所有的约束、触发器和业务规则都必须得到满足。
                    </p>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1719976354239-fc1f285a-3c90-46ff-83d6-ecec743b4d49.png" alt="一致性示意图" class="rounded-lg mb-4 w-full h-auto">
                    <div class="bg-green-50 p-4 rounded-lg">
                        <h4 class="font-bold text-green-700 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 实现机制
                        </h4>
                        <ul class="list-disc pl-5 space-y-1 text-green-800">
                            <li>约束检查 (Constraint Checking)</li>
                            <li>触发器 (Triggers)</li>
                            <li>数据类型和范围检查</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Isolation -->
                <div class="bg-white rounded-xl p-6 shadow-lg acid-card">
                    <div class="flex items-center mb-4">
                        <div class="bg-purple-100 text-purple-600 p-3 rounded-full mr-4">
                            <i class="fas fa-user-shield text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">隔离性 (Isolation)</h3>
                    </div>
                    <p class="mb-4">
                        隔离性确保并发执行的事务互不干扰，防止脏读、不可重复读和幻读等问题。
                    </p>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1719976370507-bdb801de-7505-4d19-bd41-5661033446d8.png" alt="隔离性示意图" class="rounded-lg mb-4 w-full h-auto">
                    <div class="bg-purple-50 p-4 rounded-lg">
                        <h4 class="font-bold text-purple-700 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 隔离级别
                        </h4>
                        <ul class="list-disc pl-5 space-y-1 text-purple-800">
                            <li>读未提交 (Read Uncommitted)</li>
                            <li>读已提交 (Read Committed)</li>
                            <li>可重复读 (Repeatable Read)</li>
                            <li>可序列化 (Serializable)</li>
                        </ul>
                    </div>
                </div>
                
                <!-- Durability -->
                <div class="bg-white rounded-xl p-6 shadow-lg acid-card">
                    <div class="flex items-center mb-4">
                        <div class="bg-red-100 text-red-600 p-3 rounded-full mr-4">
                            <i class="fas fa-shield-alt text-2xl"></i>
                        </div>
                        <h3 class="text-2xl font-bold">持久性 (Durability)</h3>
                    </div>
                    <p class="mb-4">
                        持久性确保已提交事务的变更永久保存，即使系统发生故障也不会丢失。
                    </p>
                    <img src="https://cdn.nlark.com/yuque/0/2024/png/21449790/1719976386424-41f31839-e6bf-4736-8542-0d694c864496.png" alt="持久性示意图" class="rounded-lg mb-4 w-full h-auto">
                    <div class="bg-red-50 p-4 rounded-lg">
                        <h4 class="font-bold text-red-700 mb-2 flex items-center">
                            <i class="fas fa-lightbulb mr-2"></i> 实现机制
                        </h4>
                        <ul class="list-disc pl-5 space-y-1 text-red-800">
                            <li>事务日志 (Transaction Log)</li>
                            <li>写提前日志 (Write-Ahead Logging)</li>
                            <li>数据库检查点 (Checkpointing)</li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>

        <!-- Real-world Example -->
        <section class="mb-20">
            <div class="bg-white rounded-xl p-8 shadow-lg acid-card">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 font-serif section-title">银行转账示例</h2>
                <p class="mb-6">
                    让我们通过一个银行转账的例子来理解ACID特性如何共同工作以保证数据的一致性和可靠性。
                </p>
                
                <div class="mermaid">
                    flowchart TD
                    A[开始转账事务] --> B[检查账户A余额]
                    B --> C{余额 ≥ 转账金额?}
                    C -->|是| D[从账户A扣除金额]
                    C -->|否| E[返回错误]
                    D --> F[向账户B增加金额]
                    F --> G[记录交易日志]
                    G --> H[提交事务]
                    H --> I[转账成功]
                </div>
                
                <div class="grid md:grid-cols-4 gap-4 mt-8">
                    <div class="bg-blue-50 p-4 rounded-lg text-center">
                        <div class="text-blue-600 mb-2">
                            <i class="fas fa-atom text-2xl"></i>
                        </div>
                        <h4 class="font-bold">原子性</h4>
                        <p class="text-sm">扣款和存款要么都完成，要么都不完成</p>
                    </div>
                    <div class="bg-green-50 p-4 rounded-lg text-center">
                        <div class="text-green-600 mb-2">
                            <i class="fas fa-balance-scale text-2xl"></i>
                        </div>
                        <h4 class="font-bold">一致性</h4>
                        <p class="text-sm">确保转账前后总金额不变</p>
                    </div>
                    <div class="bg-purple-50 p-4 rounded-lg text-center">
                        <div class="text-purple-600 mb-2">
                            <i class="fas fa-user-shield text-2xl"></i>
                        </div>
                        <h4 class="font-bold">隔离性</h4>
                        <p class="text-sm">其他事务看不到转账中间状态</p>
                    </div>
                    <div class="bg-red-50 p-4 rounded-lg text-center">
                        <div class="text-red-600 mb-2">
                            <i class="fas fa-shield-alt text-2xl"></i>
                        </div>
                        <h4 class="font-bold">持久性</h4>
                        <p class="text-sm">转账成功后数据永久保存</p>
                    </div>
                </div>
            </div>
        </section>

        <!-- Summary -->
        <section class="mb-20">
            <div class="bg-gradient-to-r from-blue-500 to-blue-600 text-white rounded-xl p-8 shadow-lg">
                <h2 class="text-2xl md:text-3xl font-bold mb-6 font-serif">ACID特性总结</h2>
                <div class="grid md:grid-cols-2 gap-8">
                    <div>
                        <h3 class="text-xl font-bold mb-4 flex items-center">
                            <i class="fas fa-check-circle mr-2"></i> 为什么ACID很重要？
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-check mt-1 mr-2"></i>
                                <span>确保数据在任何情况下都保持一致和准确</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check mt-1 mr-2"></i>
                                <span>防止数据损坏和部分更新导致的业务问题</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check mt-1 mr-2"></i>
                                <span>为关键业务操作提供可靠的数据保障</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-check mt-1 mr-2"></i>
                                <span>简化开发者的错误处理和并发控制工作</span>
                            </li>
                        </ul>
                    </div>
                    <div>
                        <h3 class="text-xl font-bold mb-4 flex items-center">
                            <i class="fas fa-database mr-2"></i> 数据库实现
                        </h3>
                        <ul class="space-y-3">
                            <li class="flex items-start">
                                <i class="fas fa-server mt-1 mr-2"></i>
                                <span><strong>MySQL</strong> (InnoDB): WAL, MVCC, 锁机制</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-server mt-1 mr-2"></i>
                                <span><strong>PostgreSQL</strong>: WAL, 多版本并发控制</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-server mt-1 mr-2"></i>
                                <span><strong>Oracle</strong>: 回滚段, 读一致性</span>
                            </li>
                            <li class="flex items-start">
                                <i class="fas fa-server mt-1 mr-2"></i>
                                <span><strong>SQL Server</strong>: 锁机制, 日志传送</span>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </section>
    </div>

    <!-- Footer -->
    <footer class="bg-gray-900 text-gray-300 py-12">
        <div class="container mx-auto max-w-5xl px-4 md:px-0">
            <div class="text-center">
                <h3 class="text-xl font-bold text-white mb-2">技术小馆</h3>
                <p class="mb-6">探索技术世界的知识宝库</p>
                <div class="flex justify-center space-x-4">
                    <a href="http://www.yuque.com/jtostring" class="text-blue-400 hover:text-blue-300 transition-colors flex items-center">
                        <i class="fas fa-globe mr-2"></i> 语雀地址
                    </a>
                </div>
                <div class="mt-8 pt-6 border-t border-gray-800 text-sm text-gray-500">
                    &copy; 2023 技术小馆. 保留所有权利.
                </div>
            </div>
        </div>
    </footer>

    <script>
        mermaid.initialize({
            startOnLoad: true,
            theme: 'default',
            flowchart: {
                useMaxWidth: true,
                htmlLabels: true,
                curve: 'basis'
            }
        });
        
        // 平滑滚动
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    </script>
</body>
</html>
```